package Demo16;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-12-20
 * Time: 15:03
 */
public class Main {
    public static void main(String[] args) {

        Book b[] = new Book[5];
        b[0] = new Book("java程序设计教程", 105.5);
        b[1] = new Book("高数教程", 99.5);
        b[2] = new Book("英语教程", 56.5);
        b[3] = new Book("图形设计教程", 98.8);
        b[4] = new Book("网络教程", 119.4);

        for (int i = 0; i < b.length; i++) {
            System.out.println(b[i].toString());
        }
    }
}

class Book {
    public String name;
    public static int num;
    public double price;
    public int n;

    Book() {
    }

    public Book(String name, double price) {
        this.name = name;
        this.price = price;
        num++;
        n = num;
    }

    @Override
    public String toString() {
        return "编号：" + n + "，书名：" + name + "，价格：" + price;
    }
}